Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
How to change "/" in the first word with function if it has 3 words and 2 words are invalid

I have 3 variables

let oneWord = "offering" 
let twoWord = "test_offering"  
let threeWord = "loan_offering_data"

I want to make where if the value of TwoWord is executed/displayed as test-offering and suppose the value of threeWord is executed/displayed it becomes loan/offering-data

how to make a function to meet the above criteria dynamic?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

function reformat(word) {
    const wds=word.split("_");
    if (wds.length ===1) return word;
    if (wds.length ===2) return wds.join("-");
    if (wds.length ===3) return `${wds[0]}/${wds[1]}-${wds[2]}`;
    throw new Error("too many words");
}
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda